package moodish.comm;

import java.io.Serializable;

public class ServerMessage implements ServerSideMessage,Serializable {

	private static final long serialVersionUID = 2738986680269847303L;

	private Type type;
	private String payload;
	private String clientNickname;

	/**
	 * The constructor of a message which is being sent from the client
	 * 
	 * @param type represents the type of a message 
	 * @param payload represents optional information about the message
	 * @param clientNickname represents the nickname of the sender
	 */

	public ServerMessage(Type type, String payload, String clientNickname) {
		this.type = type;
		this.payload = payload;
		this.clientNickname = clientNickname;
	}

	/** 
	 * @see moodish.comm.ServerSideMessage#getType()
	 */
	@Override	
	public Type getType() {
		return type;
	}	
	
	/** 
	 * @see moodish.comm.ServerSideMessage#getPayload()
	 */
	@Override
	public String getPayload() {
		return payload;
	}

	/**
	 * @see moodish.comm.ServerSideMessage#getClientNickname()
	 */
	@Override	
	public String getClientNickname() {
		return clientNickname;
	}

	@Override
	public String toString() {
		return "ServerMessage [type=" + type + ", payload=" + payload
				+ ", clientNickname=" + clientNickname + "]";
	}

}
